﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ProductManager.bl
{
    class BLCategory
    {

        public bool ValidateAdd(string name, string description)
        {

            bool check = true;
            string error = "Error:" +
                            "\n============================\n";

            string validateName = ValidateName(name);
            if (!validateName.Equals(""))
            {
                check = false;
                error = error + validateName;
            }

            string validateDescription = ValidateDescription(description);
            if (!validateDescription.Equals(""))
            {
                check = false;
                error = error + validateDescription;
            }

            if (check)
            {
                return true;
            }
            else
            {
                System.Windows.Forms.MessageBox.Show(error, "Error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                return false;
            }
        }


        public bool ValidateSearchByName(string name)
        {
            bool check = true;
            string error = "Error:" +
                            "\n============================\n";

            string validateName = ValidateName(name);
            if (!validateName.Equals(""))
            {
                check = false;
                error = error + validateName;
            }

            if (check)
            {
                return true;
            }
            else
            {
                System.Windows.Forms.MessageBox.Show(error, "Error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                return false;
            }
        }

        public string ValidateName(string name)
        {
            string error = "";

            if ("".Equals(name))
            {
                error += "\n+ Name can't empty.";
            }

            return error;
        }

        public string ValidateDescription(string description)
        {
            string error = "";

            if ("".Equals(description))
            {
                error += "\n+ Description can't empty.";
            }
            return error;
        }
    }
}
